/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2022-12-31     wgz       the first version
 */
#include "display_task.h"

#include <rtthread.h>
#include <rtdevice.h>
#include <rtdbg.h>
#include <rthw.h>
#include "bsp_display.h"
#include "mid_share_param.h"

#define OLED_LINE_1     0
#define OLED_LINE_2     16
#define OLED_LINE_3     32
#define OLED_LINE_4     48


//static uint8_t temperature_buf[20];
//static uint8_t humidity_buf[20];
extern int D_IN_4;

static void humiture_display(void)
{
    OLED_ShowString(5,OLED_LINE_1," Alarm display",16,1);  //鏍囬
//    sprintf(temperature_buf, "t: %d", (int)share_param.temperature);
//        sprintf(humidity_buf, "h: %d", (int)share_param.humidity);
////        sprintf(temperature_buf, "t: %d", temp);
////            sprintf(humidity_buf, "h: %d", humi);
//    OLED_ShowString(36, OLED_LINE_2 + 8, temperature_buf, 12,1);          //娓╁害
//    OLED_ShowString(36, OLED_LINE_3 + 12, humidity_buf, 12,1);         //婀垮害
//        if(D_IN_4=1)
//    {
//        OLED_ShowString(5,OLED_LINE_2,"Something passes",12,1);  //鏍囬
//                    }

    OLED_Refresh();


}

/* 鏄剧ず浠诲姟涓诲嚱鏁� */
void  display_task(void *parameter)
{
    uint32_t temp_level;

    temp_level = rt_hw_interrupt_disable();     //寮�鍚浂鐣岀偣淇濇姢
    oled_init();
    OLED_ColorTurn(0);//0姝ｅ父鏄剧ず锛�1 鍙嶈壊鏄剧ず
    OLED_DisplayTurn(0);//0姝ｅ父鏄剧ず 1 灞忓箷缈昏浆鏄剧ず
    OLED_Clear();
    rt_hw_interrupt_enable(temp_level);         //鍏抽棴淇濇姢


    while (1)
    {
        humiture_display();
        rt_thread_mdelay(50);
    }

}
